package com.hzlj.position.config.common.dto.operatorConfig;

import com.hzlj.position.config.common.enums.WarningType;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @author lifh
 * @date 2023/7/7 19:53
 **/
@Data
public class OperatorConfigExtDTO {
    /**
     * serviceIds
     * key=jgCode
     * value=serviceId
     */
    private Map<String, String> serviceIds;
    /**
     * 关机代码
     */
    private List<String> shutdowns;
    /**
     * 未开通代码
     */
    private List<String> notOpens;

    /**
     * 需要重新定位的代码
     */
    private List<String> reLocates;

    /**
     * 需要抽查的代码：注意关机会做轨迹确认，所以关机不应该在这里出现
     */
    private List<String> inspections;

    public boolean shutdown(String code) {
        return shutdowns != null && shutdowns.contains(code);
    }

    public boolean notOpen(String code) {
        return notOpens != null && notOpens.contains(code);
    }


    public WarningType checkWarningType(String code) {
        //关机
        if (shutdown(code)) {
            return WarningType.POWER_OFF;
        }
        //未开通
        if (notOpen(code)) {
            return WarningType.NOT_OPEN;
        }
        return null;
    }

    public boolean reLocate(String code) {
        return code != null && reLocates != null && reLocates.contains(code);
    }

    public boolean inspection(String code) {
        return code != null && inspections != null && inspections.contains(code);
    }
}
